package com.juyu.miliao.api.rabbitMQ;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juyu.miliao.common.constant.BillDetailBeansMqKey;
import com.juyu.miliao.common.constant.LuckDrawPrizeMqKey;
import com.juyu.miliao.common.domain.dto.BillDetailBeansDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Auther: 卜加超
 * @Date: 2019/7/19 09:05
 * @Description:
 */
@Slf4j
@Component
public class LuckDrawPrizeMq {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @Autowired
    private ObjectMapper objectMapper;

    public void getLuckDrawPrizeMq(JSONObject value){
        try {
            if (value != null) {
                amqpTemplate.convertAndSend(LuckDrawPrizeMqKey.LUCK_DRAW_PRIZE_EXCHANGE_KEY,
                        LuckDrawPrizeMqKey.LUCK_DRAW_PRIZE_ROUNTING_KEY,
                        objectMapper.writeValueAsString(value));
            }
        }catch (Exception ex){
            log.info("添加中奖信息放入队列失败：{}", value);
        }
    }
}
